home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 8 / FM Towns Free Software Collection 8.iso / t_os / artemis / artsrc2 / gpsetbk.asm < prev    next >
Assembly Source File  |  1994-06-01  |  5KB  |  291 lines

  1. ;    Rio's Graphic Library
  2. ;
  3. ;    gpset.asm
  4. ;
  5. ;    1992.6.13(Sat)
  6.  
  7.         public    _gpset, gpset
  8.         extrn    _gwrtreg:near
  9.         
  10.         include    grplib.inc
  11.         
  12.         assume    cs:cseg
  13.  
  14. dseg segment
  15.  
  16. px        dd    0
  17. py        dd    0
  18. pcol        dd    0
  19. plog        dd    0
  20.  
  21. dseg ends
  22.  
  23. cseg segment
  24.  
  25. ;---------------------------------------------------------------
  26. ;    _gpset : 点の描画
  27. ;        in  AX,BX : 座標
  28. ;            CX    : 色
  29. ;            DX    : 演算指定(0=PSET 1=XOR)
  30. ;
  31. ;    void gpset(int x, int y, int col, int mode)
  32. ;---------------------------------------------------------------
  33.  
  34.         align    4
  35.  
  36. gpset        proc
  37.         mov    ax,[esp+4]
  38.         mov    [px],ax
  39.         mov    ax,[esp+8]
  40.         mov    [py],ax
  41.         mov    ax,[esp+12]
  42.         mov    [pcol],ax
  43.         mov    ax,[esp+16]
  44.         mov    [plog],ax
  45.         push    dword ptr offset #retp
  46.         mov    al,[_nowscrmod]
  47.         cmp    al,2
  48.         jle    #nomode
  49.         cmp    al,4
  50.         jle    gpset_16
  51.         cmp    al,8
  52.         jle    gpset_32_1
  53.         cmp    al,11
  54.         jle    gpset_32_2
  55.         cmp    al,14
  56.         jle    gpset_256
  57.         cmp    al,18
  58.         jle    gpset_32_3
  59. #nomode:    ret
  60. #retp:        ret
  61. gpset        endp
  62.  
  63.         align    4
  64.  
  65. gpset_16    proc
  66. gpset_16    endp
  67.  
  68. gpset_32_1    proc
  69. gpset_32_1    endp
  70.  
  71. gpset_32_2    proc
  72. gpset_32_2    endp
  73.  
  74. gpset_256    proc
  75. gpset_256    endp
  76.  
  77. gpset_32_3    proc
  78. gpset_32_3    endp
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.         push    ebx
  86.         push    esi
  87.         mov    al,[_nowscrmod]
  88.         cmp    al,2
  89.         jle    #end
  90.         cmp    al,4
  91.         jle    #mode16
  92.         cmp    al,8
  93.         jle    #mode32K_256
  94.         cmp    al,11
  95.         jle    #mode32K_512
  96.         jmp    #end
  97.  
  98.  
  99. #mode16:
  100. parmbase = 12
  101.         mov    ax,[esp+parmbase+4]    ;y
  102.         and    eax,0ffffh
  103.         lea    eax,[eax*8]
  104.         lea    eax,[eax*8]
  105.         lea    eax,[eax*8]
  106.         mov    bx,[esp+parmbase]    ;x
  107.         and    ebx,0ffffh
  108.         mov    ecx,ebx
  109.         shr    ebx,1
  110.         add    eax,ebx            ;eax := アドレス
  111.         bt    ecx,0
  112.         jnc    #odd
  113. #even:        mov    ebx,0fh            ;mask
  114.         mov    ecx,[esp+parmbase+8]    ;color
  115.         and    ecx,0fh
  116.         shl    ecx,4
  117.         jmp    #m16_l1
  118. #odd:        mov    ebx,0f0h        ;mask
  119.         mov    ecx,[esp+parmbase+8]    ;color
  120.         and    ecx,0fh
  121. #m16_l1:    push    ds
  122.         mov    si,104h
  123.         mov    ds,si
  124.         mov    edx,[esp+parmbase+12]    ;logop
  125.         or    edx,edx
  126.         jnz    #m16_xor
  127. #m16_normal:    mov    dl,ds:[eax]
  128.         and    dl,bl
  129.         or    dl,cl
  130.         jmp    #m16_l2
  131. #m16_xor:    mov    dl,ds:[eax]
  132.         xor    dl,cl
  133. #m16_l2:    mov    ds:[eax],dl
  134.         pop    ds
  135.         jmp    #end
  136.  
  137. #mode32K_256:
  138. parmbase = 12
  139.         mov    ax,[esp+parmbase+4]    ;y
  140.         and    eax,0ffffh
  141.         lea    eax,[eax*8]
  142.         lea    eax,[eax*8]
  143.         lea    eax,[eax*8]
  144.         jmp    #mode32K_
  145. #mode32K_512:
  146. parmbase = 12
  147.         mov    ax,[esp+parmbase+4]    ;y
  148.         and    eax,0ffffh
  149.         lea    eax,[eax*8]
  150.         lea    eax,[eax*8]
  151.         lea    eax,[eax*8]
  152.         add    eax,eax
  153.  
  154. #mode32K_:
  155.         mov    bx,[esp+parmbase]    ;x
  156.         and    ebx,0ffffh
  157.         add    ebx,ebx
  158.         add    eax,ebx            ;eax := address
  159.         push    ds
  160. parmbase = parmbase + 2
  161.         mov    bx,120h
  162.         mov    ds,bx
  163.         mov    bx,[esp+parmbase+12]    ;logop
  164.         or    bx,bx
  165.         jnz    #m32_xor
  166. #m32_normal:    mov    bx,[esp+parmbase+8]    ;col
  167.         mov    ds:[eax],bx
  168.         jmp    #m32_l1
  169. #m32_xor:    mov    bx,[esp+parmbase+8]
  170.         xor    ds:[eax],bx
  171. #m32_l1:    pop    ds
  172.         jmp    #end
  173.  
  174. #end:
  175.         pop    esi
  176.         pop    ebx
  177.         ret
  178.  
  179. ;        push    ebx
  180. ;        mov    ax,[esp+8]
  181. ;        mov    bx,[esp+12]
  182. ;        mov    cx,[esp+16]
  183. ;        mov    dx,[esp+20]
  184. ;        call    _gpset
  185. ;        pop    ebx
  186. ;        ret
  187. gpset        endp
  188.  
  189.         align    4
  190.  
  191. _gpset        proc
  192.         pushad
  193.         mov    di,dx        ;DI := 演算指定
  194.         mov    si,cx        ;SI := カラーコード
  195.         mov    cl,[_nowscrmod]
  196.         cmp    cl,2
  197.         jle    #end
  198.         cmp    cl,4
  199.         jle    #mode0
  200.         cmp    cl,8
  201.         jle    #mode2
  202.         cmp    cl,11
  203.         jle    #mode1
  204.         jmp    #end
  205. #mode0:        ;            《仮想画面 1024*512,16色モード》
  206.         mov    ecx,eax
  207.         and    ecx,7
  208.         lea    ecx,[ecx*4]    ;ESI := 書き込むピクセルデータ
  209.         shl    esi,cl
  210.         mov    ebp,1111b    ;EBP := マスクパターン
  211.         shl    ebp,cl
  212.         and    ebx,0ffffh    ;EBX := アドレス
  213.         lea    ebx,[ebx*8]
  214.         lea    ebx,[ebx*8]
  215.         lea    ebx,[ebx*8]
  216.         and    eax,0fff8h
  217.         shr    eax,1
  218.         add    ebx,eax
  219.         mov    al,[_wrtpage]
  220.         or    al,al
  221.         jz    #mode0_page0
  222.         add    ebx,40000h
  223. #mode0_page0:    ;
  224.         xor    ax,ax        ;マスクレジスタ書き込み
  225.         mov    edx,ebp
  226.         call    _gwrtreg
  227.         push    ds        ;VRAM 書き込み
  228.         mov    ax,104h
  229.         mov    ds,ax
  230.         or    di,di        ;(演算指定により分岐)
  231.         jnz    #mode0_xor
  232.         mov    ds:[ebx],esi
  233.         jmp    #mode0_end
  234. #mode0_xor:    xor    ds:[ebx],esi
  235. #mode0_end:    pop    ds
  236.         jmp    #end
  237. #mode1:        ;            《仮想画面 512*256,32768色モード》
  238.         and    ebx,0ffffh    ;EBX := アドレス
  239.         lea    ebx,[ebx*8]
  240.         lea    ebx,[ebx*8]
  241.         lea    ebx,[ebx*8]
  242.         lea    ebx,[ebx*2]
  243.         and    eax,0ffffh
  244.         add    eax,eax
  245.         add    ebx,eax
  246.         mov    al,[_wrtpage]
  247.         or    al,al
  248.         jz    #mode1_page0
  249.         add    ebx,40000h
  250. #mode1_page0:    ;
  251.         push    ds
  252.         mov    ax,104h
  253.         mov    ds,ax
  254.         or    di,di
  255.         jnz    #mode1_xor
  256.         mov    ds:[ebx],si
  257.         jmp    #mode1_end
  258. #mode1_xor:    xor    ds:[ebx],si
  259. #mode1_end:    pop    ds
  260.         jmp    #end
  261. #mode2:        ;            《仮想画面 256*512,32768色モード》
  262.         and    ebx,0ffffh    ;EBX := アドレス        
  263.         lea    ebx,[ebx*8]
  264.         lea    ebx,[ebx*8]
  265.         lea    ebx,[ebx*8]
  266.         and    eax,0ffffh
  267.         add    eax,eax
  268.         add    ebx,eax
  269.         mov    al,[_wrtpage]
  270.         or    al,al
  271.         jz    #mode2_page0
  272.         add    ebx,40000h
  273. #mode2_page0:    ;
  274.         push    ds
  275.         mov    ax,104h
  276.         mov    ds,ax
  277.         or    di,di
  278.         jnz    #mode2_xor
  279.         mov    ds:[ebx],si
  280.         jmp    #mode2_end
  281. #mode2_xor:    xor    ds:[ebx],si
  282. #mode2_end:    pop    ds
  283. #end:        ;            後処理
  284.         popad
  285.         ret
  286. _gpset        endp
  287.  
  288. cseg ends
  289.  
  290. end
  291.